package com.wlr.blog.util.common.config;

import org.springframework.boot.SpringBootVersion;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.Set;

/**
 * @author lrwang
 * @version 1.0
 * @date 2022/11/7 16:28
 */
@Configuration
@EnableSwagger2WebMvc
public class SwaggerConfiguration {
//    private final SwaggerProperties swaggerProperties;
//
//    public SwaggerConfiguration(SwaggerProperties swaggerProperties) {
//        this.swaggerProperties = swaggerProperties;
//    }

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build();
    }

    public ApiInfo apiInfo() {
        return new ApiInfoBuilder().title("HustleLr博客的接口文档")
                .description("HustleLr博客的接口文档")
                .contact(new Contact("lighter", null, "alexmail1205@163.com"))
                .termsOfServiceUrl("https://www.bloglr.top/api")
                .version("Application Version: 1.0.0 SpringBoot Version: " + SpringBootVersion.getVersion())
                .build();
    }
}
